package com.xongxong.admin.web.controller;

import com.google.common.cache.Cache;
import com.xongxong.admin.common.response.Response;
import com.xongxong.admin.service.UserInfoService;
import com.xongxong.admin.web.config.loginCommon.annotation.CheckOutLogin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Fuzhengwei bugstack.cn @小傅哥
 * @description
 * @create 2024-09-27 16:59
 */


@RestController
@ResponseBody
public class XxxController {
    @Resource
    private UserInfoService userInfoServiceImpl;
    @Resource
    private Cache<String, String> cache;

    @CheckOutLogin
    @GetMapping("/list")
    public Response test() {
        return Response.ok("200","成功",userInfoServiceImpl.list());
    }


    @GetMapping("/get")
    public void get() {
        String ifPresent = cache.getIfPresent("qwert");
        System.out.printf("ifPresent" + ifPresent);
    }

    @GetMapping("/setUserInfo")
    public String setUserInfo() {
        cache.put("key", "value");
        return "success";

    }


    @CheckOutLogin
    @GetMapping("/getUserInfo")
    public String getUserInfo() {
        return cache.getIfPresent("key");
    }
}
